package com.tgr.shortLink.project.common.config;

import org.redisson.api.RBloomFilter;
import org.redisson.api.RedissonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 描述：布隆过滤器配置
 * 作者：小陶不慌张
 * 文件：RBloomFilterConfiguration
 * 日期：2023/12/23 23:46
 */

@Configuration("rBloomFilterConfigurationByProject")
public class RBloomFilterConfiguration {
    /**
     * 防止短链接创建查询数据库的布隆过滤器
     */
    @Bean
    public RBloomFilter<String> shortUrlCreateCachePenetrationBloomFilter(RedissonClient redissonClient){
        RBloomFilter<String> cachePenetrationBloomFilter = redissonClient.getBloomFilter("shortUrlCreateCachePenetrationBloomFilter");
        cachePenetrationBloomFilter.tryInit(100000000,0.01);
        return cachePenetrationBloomFilter;
    }
}
